// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;

#include "MySqlShowHMSMetaStatement.h"
#include "../../../../ast/SQLName.h"
#include "../../../../ast/expr/SQLPropertyExpr.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../../utils/instanceof.h"

SQLName_ptr MySqlShowHMSMetaStatement::getName()
{
  return name;
}

void MySqlShowHMSMetaStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

string_ptr MySqlShowHMSMetaStatement::getSchema()
{
  if (instanceof <SQLName, SQLPropertyExpr>(name))
  {
    return (std::dynamic_pointer_cast<SQLPropertyExpr>(name))->getOwnernName();
  }
  return nullptr;
}

string_ptr MySqlShowHMSMetaStatement::getTableName()
{
  return name->getSimpleName();
}

void MySqlShowHMSMetaStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlShowHMSMetaStatement)))
  {
    acceptChild(visitor, name);
  }
  visitor->endVisit(SharedObject(MySqlShowHMSMetaStatement));
}
